package com.rainwood.water_authority.ui.adapter;
import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.rainwood.water_authority.R;
import com.rainwood.water_authority.base.MyBaseAdapter;
import com.rainwood.water_authority.http.response.ShouLiaoListBean;
import com.rainwood.water_authority.model.MaterialBean;

/**
 * @author sxs
 * @date :2020/9/28
 * @desc: 物资入库适配器
 */
public  class ShouLioListAdapter extends MyBaseAdapter<ShouLiaoListBean.DataBean.RecordBean> {
     private int type;
    public ShouLioListAdapter(@NonNull Context context,int type) {
        super(context);
        this.type=type;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private class ViewHolder extends MyBaseAdapter.ViewHolder{

        private final TextView tv_issue_name;
        private final TextView tv_planNum;
        private final TextView tv_num;
        private final TextView tv_material_code;
        private final TextView tv_model;
        private final TextView tv_unit,btn_outbound;

        public ViewHolder() {
            super(R.layout.item_shouliaolist_bills);
            tv_issue_name = (TextView) findViewById(R.id.tv_issue_name);
            tv_planNum = (TextView) findViewById(R.id.tv_planNum);
            tv_num = (TextView) findViewById(R.id.tv_num);
            tv_material_code = (TextView) findViewById(R.id.tv_material_code);
            tv_model = (TextView) findViewById(R.id.tv_model);
            tv_unit = (TextView) findViewById(R.id.tv_unit);
            btn_outbound= (TextView) findViewById(R.id.btn_outbound);
        }

        @Override
        public void onBindView(int position) {
            tv_issue_name.setText(getItem(position).getMaterial().getName());
            tv_planNum.setText(getItem(position).getPlanNum());
            tv_num.setText(getItem(position).getNum());
            tv_material_code.setText(getItem(position).getMaterial().getCode());
            tv_model.setText(getItem(position).getMaterial().getModel());
            tv_unit.setText(getItem(position).getMaterial().getUnit());
            if (type==0){
                btn_outbound.setText("收料");
            }else {
                btn_outbound.setText("发料");
            }
        }
    }
}
